package com.tanovo.service;

import com.tanovo.bo.EsBatchAddReq;
import com.tanovo.bo.IndexBo;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexResponse;

public interface EsService {
    /**
     * 获取 client对象
     *
     * @return
     */
    RestHighLevelClient getHighClient();

    /**
     * 创建添加索引
     *
     * @param esBatchAddReq
     */
    BulkResponse upsetIndex(EsBatchAddReq esBatchAddReq);

    /**
     * 创建索引
     *
     * @param indexName
     * @return
     */
    CreateIndexResponse createIndex(String indexName);

    /**
     * 判断索引是否存在
     *
     * @param indexName
     * @return
     */
    Boolean existIndex(String indexName);

    /**
     * 删除索引
     *
     * @param indexName
     * @return
     */
    AcknowledgedResponse deleteIndex(String indexName);

    /**
     * 判断文档是否存在
     *
     * @return
     */
    Boolean existDoc(IndexBo indexBo);

    /**
     * 获取文档详情
     *
     * @param indexBo
     * @return
     */
    GetResponse getDocInfo(IndexBo indexBo);

    /**
     * 更新文档信息
     *
     * @param indexBo
     * @return
     */
    UpdateResponse updateDocInfo(IndexBo indexBo);

    /**
     * 删除文档信息
     * @param indexBo
     * @return
     */
    DeleteResponse deleteDocInfo(IndexBo indexBo);
}
